/* 超管面板专用样式(GitHub 风格,与 portal/style.css 协调) */

.admin-page { display: flex; flex-direction: column; }

.crumb { color: var(--gh-fg-muted); font-weight: normal; margin-left: 6px; font-size: 14px; }

.admin-nav {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--gh-bg);
  border-bottom: 1px solid var(--gh-border);
  overflow-x: auto;
}
.admin-tab {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--gh-fg-muted);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: all .15s;
}
.admin-tab:hover:not(:disabled) { color: var(--gh-fg); }
.admin-tab.active {
  color: var(--gh-accent);
  border-bottom-color: var(--gh-accent);
  font-weight: 600;
}
.admin-tab:disabled { opacity: .4; cursor: not-allowed; }

.admin-main {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.admin-section { display: none; }
.admin-section.active { display: block; }

/* 监控仪表盘 */
.dash-cards { display: flex; flex-direction: column; gap: 18px; }
.dash-group { background: var(--gh-bg); border: 1px solid var(--gh-border);
              border-radius: var(--gh-radius); padding: 16px; }
.dash-group-head { display: flex; align-items: center; justify-content: space-between;
                   margin-bottom: 12px; }
.dash-group-head h3 { margin: 0; font-size: 14px; color: var(--gh-fg-muted); font-weight: 600; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
             gap: 12px; }
.dash-card { padding: 12px 14px; background: #f6f8fa;
             border-radius: var(--gh-radius); border: 1px solid var(--gh-border-muted); }
.dash-val { font-size: 24px; font-weight: 600; color: var(--gh-fg); line-height: 1.1; }
.dash-label { font-size: 12px; color: var(--gh-fg-muted); margin-top: 4px; }
.dash-hint { font-size: 10px; color: var(--gh-fg-subtle); margin-top: 4px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.users-table-wrap {
  background: var(--gh-bg);
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  overflow-x: auto;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.users-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid var(--gh-border);
  font-weight: 600;
  color: var(--gh-fg);
  white-space: nowrap;
}
.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gh-border-muted);
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: 0; }
.users-table tr.row-owner { background: rgba(240, 180, 41, .08); }

.role-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.role-pill.role-superadmin { background: #ffebe9; color: #cf222e; }
.role-pill.role-management,
.role-pill.role-admin { background: #ddf4ff; color: #0969da; }
.role-pill.role-operations { background: #dafbe1; color: #1f883d; }
.role-pill.role-finance { background: #fff8c5; color: #7d4e00; }
.role-pill.role-sales { background: #e7d9fd; color: #6f42c1; }
.role-pill.role-customer { background: #f6f8fa; color: #656d76; }
.role-pill.role-pending { background: #fff7e6; color: #b08800; }
.role-pill.role-none { background: #f6f8fa; color: #9ba1a8; }
.role-pill.owner { background: #fce5a1; color: #5a4200; }

.users-table .actions { white-space: nowrap; }
.act-btn {
  border: none;
  background: transparent;
  color: var(--gh-accent);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  margin-right: 4px;
  border-radius: 3px;
}
.act-btn:hover { background: #ddf4ff; }
.act-btn.act-danger { color: var(--gh-danger); }
.act-btn.act-danger:hover { background: #ffebe9; }

.empty-tip {
  text-align: center;
  color: var(--gh-fg-muted);
  padding: 40px;
}

/* ── modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 40, .5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--gh-bg);
  border-radius: var(--gh-radius);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h3 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 600;
}

.user-form label {
  display: block;
  margin-bottom: 14px;
}
.user-form label span {
  display: block;
  font-size: 13px;
  color: var(--gh-fg-muted);
  margin-bottom: 6px;
}
.user-form em {
  color: var(--gh-danger);
  font-style: normal;
}
.user-form input,
.user-form select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  font-size: 14px;
  background: var(--gh-bg);
  color: var(--gh-fg);
  box-sizing: border-box;
}
.user-form input:focus,
.user-form select:focus {
  outline: none;
  border-color: var(--gh-accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, .15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ── 筛选栏(账号 / 角色权限通用)── */
.filter-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: #f6f8fa;
  border: 1px solid var(--gh-border);
  border-radius: 6px;
}
.filter-label { font-size: 11px; color: #656d76; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.chips { display: inline-flex; gap: 4px; }
.chip {
  background: #fff; border: 1px solid var(--gh-border); color: var(--gh-fg);
  padding: 4px 10px; font-size: 12px; border-radius: 16px; cursor: pointer;
  transition: all .12s;
}
.chip:hover { background: #f0f3f6; }
.chip.active { background: var(--gh-fg); color: #fff; border-color: var(--gh-fg); }
.filter-search {
  border: 1px solid var(--gh-border); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; min-width: 160px; height: 28px;
  background: #fff; color: var(--gh-fg);
}
.filter-search:focus { outline: 2px solid rgba(9,105,218,.3); border-color: var(--gh-link); }

/* ── 应用归属标签(账号管理姓名后 + 矩阵 panel head)── */
.app-tag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  font-size: 10px; font-weight: 700;
  border-radius: 9px; vertical-align: middle;
}
.app-tag.app-fleet { background: #ddf4ff; color: #0969da; border: 1px solid rgba(9,105,218,.25); }
.app-tag.app-nempoi { background: #dafbe1; color: #1f883d; border: 1px solid rgba(31,136,61,.25); }
.app-tag.app-platform { background: #f0e7ff; color: #6f42c1; border: 1px solid rgba(111,66,193,.25); }
.app-tag.app-owner { background: #fff8c5; color: #7d4e00; border: 1px solid rgba(125,78,0,.25); }

/* ── 角色权限矩阵 ── */
.matrix-wrap { padding-bottom: 20px; display: flex; flex-direction: column; gap: 16px; }
.matrix-panel {
  border: 1px solid var(--gh-border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.matrix-panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #f6f8fa;
  border-bottom: 1px solid var(--gh-border);
}
.matrix-panel-head .app-tag {
  font-size: 11px; padding: 2px 10px; height: 22px;
}
.matrix-panel-meta { font-size: 11px; color: #656d76; }
.matrix-table-wrap {
  max-height: 600px;
  overflow: auto;
  position: relative;
}
.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.matrix-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #fff;
  border-bottom: 1px solid var(--gh-border);
  padding: 10px 8px;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
}
.matrix-table th.cell-perm { text-align: left; min-width: 280px; padding-left: 14px; }
.matrix-table th.cell-role { min-width: 90px; position: relative; }
.matrix-table th.cell-role.sys { background: #fff8e1; }
.matrix-table th.cell-role.lock { background: #f6f8fa; }
.matrix-table .role-name { font-size: 12px; }
.matrix-table .role-lock-ic { margin-left: 4px; font-size: 10px; }
.matrix-table .role-del {
  position: absolute; top: 4px; right: 4px;
  width: 16px; height: 16px; padding: 0;
  background: transparent; border: 0; color: #656d76;
  font-size: 14px; cursor: pointer; border-radius: 4px;
  line-height: 1;
}
.matrix-table .role-del:hover { background: #ffebe9; color: #cf222e; }
.matrix-table td {
  padding: 8px;
  border-bottom: 1px solid var(--gh-border-muted);
  vertical-align: middle;
}
.matrix-table tbody tr:hover td { background: rgba(9,105,218,.04); }
.matrix-table td.cell-perm { text-align: left; padding-left: 14px; }
.matrix-table td.cell-perm .perm-desc { color: #1f2328; line-height: 1.3; }
.matrix-table td.cell-perm .perm-key {
  font-size: 10px; color: #656d76;
  background: rgba(175,184,193,.15);
  padding: 1px 5px; border-radius: 3px;
  margin-top: 2px; display: inline-block;
}
.matrix-table td.cell-check { text-align: center; }
.matrix-table tr.cat-row td {
  background: #ddf4ff;
  font-size: 11px;
  font-weight: 600;
  color: #0969da;
  padding: 6px 14px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(9,105,218,.2);
}
.matrix-table tbody tr.cat-row:hover td { background: #ddf4ff; }

/* iOS 风格 toggle 替代 checkbox */
.matrix-table .toggle {
  position: relative; display: inline-block;
  width: 32px; height: 18px; cursor: pointer;
  vertical-align: middle;
}
.matrix-table .toggle.disabled { cursor: not-allowed; opacity: .4; }
.matrix-table .toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.matrix-table .toggle-slider {
  position: absolute; inset: 0;
  background: #d0d7de;
  border-radius: 18px;
  transition: background .15s;
}
.matrix-table .toggle-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  background: #fff; border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.matrix-table .toggle input:checked + .toggle-slider { background: var(--gh-success); }
.matrix-table .toggle input:checked + .toggle-slider::before { transform: translateX(14px); }
.matrix-table .toggle:hover .toggle-slider { box-shadow: 0 0 0 4px rgba(9,105,218,.08); }
.matrix-table .toggle.disabled:hover .toggle-slider { box-shadow: none; }

.matrix-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 14px;
  background: #f6f8fa;
  border-top: 1px solid var(--gh-border);
}
.matrix-actions .matrix-save {
  width: auto;
  padding: 6px 14px;
  font-size: 12px;
  height: auto;
}
.matrix-actions .matrix-save:not(:disabled) {
  background: var(--gh-success);
  border-color: rgba(31,136,61,.4);
  color: #fff;
}

/* ── 系统架构页 ── */
.arch-doc h3 {
  margin: 24px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gh-border-muted);
  font-size: 15px;
  font-weight: 600;
}
.arch-doc h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  color: var(--gh-fg-muted);
}
.arch-doc .arch-list {
  margin: 0; padding: 0 0 0 20px;
  font-size: 13px;
  line-height: 1.7;
}
.arch-doc .arch-list li code {
  font-size: 11px;
  background: rgba(175, 184, 193, .2);
  padding: 1px 4px;
  border-radius: 3px;
}
.arch-pre {
  background: #f6f8fa;
  padding: 16px;
  border-radius: 6px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto;
  border: 1px solid var(--gh-border);
  line-height: 1.4;
}

/* ── 移动端 ── */
@media (max-width: 600px) {
  .admin-nav { padding: 0 8px; }
  .admin-tab { padding: 10px 12px; font-size: 12px; }
  .admin-main { padding: 12px; }
  .section-head h2 { font-size: 16px; }
  .users-table { font-size: 12px; }
  .users-table th, .users-table td { padding: 8px 6px; }
}
