/* 权限中心样式 */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1e293b;
  --soft: #64748b;
  --faint: #94a3b8;
  --border: #e8edf5;
  --brand: #4f46e5;
  --brand-deep: #3730a3;
  --brand-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --shadow: 0 10px 30px -14px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-size: 14px;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #f1f5f9; color: #0f766e; padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--soft); font-size: 13px; font-weight: 400; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; transition: .16s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px -4px rgba(79,70,229,.5); }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); }
.btn-ghost { background: var(--surface); color: var(--soft); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--brand); border-color: #c7d2fe; background: #f8faff; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.icon-btn { width: 32px; height: 32px; border: none; background: #f1f5f9; color: var(--soft); border-radius: 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: #e2e8f0; color: var(--text); }
.select-input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); font-size: 13.5px; font-family: inherit; min-width: 150px; }

/*  Gate  */
/* ==========================================================================
   登录页（分屏：左品牌展示 + 右表单）
   ========================================================================== */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: #fff; }

/* 左侧品牌区 */
.login-aside {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, #312e81 0%, #4f46e5 52%, #6d28d9 100%);
  color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  padding: 46px clamp(36px, 6vw, 84px);
}
.login-aside::before, .login-aside::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.login-aside::before { width: 460px; height: 460px; right: -170px; top: -150px; background: radial-gradient(circle, rgba(129,140,248,.55), rgba(129,140,248,0) 68%); }
.login-aside::after { width: 520px; height: 520px; left: -200px; bottom: -230px; background: radial-gradient(circle, rgba(236,72,153,.28), rgba(236,72,153,0) 68%); }
.login-aside-inner { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 13px; }
.login-brand-mark { width: 48px; height: 48px; border-radius: 13px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28); display: grid; place-items: center; overflow: hidden; backdrop-filter: blur(6px); }
.login-brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.login-brand-name { font-size: 19px; font-weight: 800; letter-spacing: .5px; line-height: 1.15; }
.login-brand-name small { display: block; font-size: 9px; font-weight: 600; letter-spacing: 2.4px; color: rgba(255,255,255,.62); margin-top: 4px; }
.login-hero { margin-top: clamp(48px, 11vh, 104px); }
.login-hero h2 { margin: 0; font-size: clamp(30px, 3.4vw, 44px); line-height: 1.28; font-weight: 800; letter-spacing: -.5px; }
.login-hero p { margin: 20px 0 0; font-size: 14.5px; line-height: 1.9; color: rgba(255,255,255,.75); }
.login-features { display: flex; flex-direction: column; gap: 18px; margin-top: clamp(36px, 7vh, 64px); }
.login-feature { display: flex; align-items: center; gap: 14px; }
.lf-ico { width: 42px; height: 42px; flex: none; display: grid; place-items: center; font-size: 18px; border-radius: 12px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); }
.login-feature b { display: block; font-size: 14px; font-weight: 700; }
.login-feature small { display: block; margin-top: 3px; font-size: 12px; color: rgba(255,255,255,.6); }
.login-aside-foot { position: relative; z-index: 1; font-size: 11.5px; color: rgba(255,255,255,.5); letter-spacing: .5px; }

/* 右侧表单区 */
.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 32px; background: var(--bg); position: relative; }
.login-card { width: 100%; max-width: 402px; background: #fff; border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 24px 60px -26px rgba(15,23,42,.22), 0 4px 14px -8px rgba(15,23,42,.05); padding: 44px 42px 38px; }
.login-card-head { text-align: center; margin-bottom: 30px; }
.login-mini-mark { width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 15px; background: linear-gradient(135deg, var(--brand), #7c3aed); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 800; box-shadow: 0 10px 22px -10px rgba(79,70,229,.75); }
.login-card-head h1 { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -.3px; }
.login-sub { margin: 8px 0 0 !important; font-size: 13.5px !important; color: var(--soft) !important; }

.login-field { margin-bottom: 19px; }
.login-field > span { margin-bottom: 9px; }
.login-input-wrap { position: relative; display: flex; align-items: center; }
.login-input-ico { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; transition: color .16s; }
.login-input-wrap input {
  width: 100%; height: 48px; padding: 0 14px 0 44px;
  border: 1.5px solid var(--border); border-radius: 11px; background: #fbfcfe;
  font-size: 14px; font-family: inherit; color: var(--text); transition: border-color .16s, box-shadow .16s, background .16s;
}
.login-input-wrap input::placeholder { color: #b3bfcf; }
.login-input-wrap input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(79,70,229,.1); }
.login-input-wrap:focus-within .login-input-ico { color: var(--brand); }

.login-error { margin: -4px 0 16px; padding: 10px 13px; border-radius: 9px; background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); font-size: 12.5px; }
.login-submit { width: 100%; height: 48px; margin-top: 2px; font-size: 15px; letter-spacing: 2px; }
.login-submit:hover:not(:disabled) { box-shadow: 0 12px 26px -10px rgba(79,70,229,.75); }
.login-card .back-link { display: block; text-align: center; margin-top: 22px; }
.login-foot-note { position: absolute; bottom: 22px; font-size: 12px; color: var(--faint); }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-main { min-height: 100vh; }
}
@media (max-width: 480px) {
  .login-card { padding: 36px 24px 30px; }
}

/* 布局 */
.app-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #101828; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), #06b6d4); color: #fff; display: grid; place-items: center; font-size: 18px; font-weight: 800; flex: none; }
.sb-brand strong { display: block; color: #fff; font-size: 15px; }
.sb-brand span { display: block; color: #64748b; font-size: 11px; margin-top: 2px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sb-group { font-size: 10px; font-weight: 700; letter-spacing: 1.4px; color: #4b5563; text-transform: uppercase; margin: 16px 10px 8px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin: 2px 0; border-radius: 9px; color: #94a3b8; text-decoration: none; font-size: 13.5px; font-weight: 500; transition: .15s; }
.nav-item .ni { width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(79,70,229,.6); }
.sb-foot { padding: 14px 20px 20px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 8px; }
.back-link { color: #64748b; text-decoration: none; font-size: 12.5px; }
.back-link:hover { color: #a5b4fc; }

.main { min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.tb-left h1 { margin: 0; font-size: 20px; font-weight: 800; }
.tb-left p { margin: 2px 0 0; color: var(--soft); font-size: 12.5px; }
.tb-right { display: flex; align-items: center; gap: 12px; }
.user-chip { background: var(--brand-soft); color: var(--brand); font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 999px; }
.content { padding: 26px 32px 60px; max-width: 1240px; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 概览 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 15px; padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.stat-ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 21px; flex: none; }
.stat-ic.c1 { background: var(--brand-soft); color: var(--brand); }
.stat-ic.c2 { background: #ecfeff; color: #0891b2; }
.stat-ic.c3 { background: #fef3c7; color: #d97706; }
.stat-ic.c4 { background: var(--ok-soft); color: var(--ok); }
.stat-num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-lb { color: var(--soft); font-size: 12px; margin-top: 5px; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.level { border: 1px solid var(--border); border-radius: 14px; padding: 20px; position: relative; overflow: hidden; background: #fff; }
.level::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.level.l1::before { background: linear-gradient(#6366f1,#818cf8); }
.level.l2::before { background: linear-gradient(#0891b2,#22d3ee); }
.level.l3::before { background: linear-gradient(#059669,#34d399); }
.lv-tag { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--faint); }
.level h3 { margin: 6px 0 4px; font-size: 16px; }
.level p { margin: 0 0 14px; color: var(--soft); font-size: 13px; }
.lv-foot { font-size: 12px; color: var(--brand); font-weight: 600; }

/* 面板与表格 */
.panel { background: #fff; border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 750; }
.head-btns { display: flex; gap: 8px; }
.tbl-wrap { overflow-x: auto; }
.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 12px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl th { background: #f8fafc; color: var(--soft); font-weight: 700; font-size: 11.5px; letter-spacing: .3px; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl .code-cell { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #0f766e; }
.tbl .empty-row { text-align: center; color: var(--faint); padding: 36px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: #f1f5f9; color: var(--soft); }
.badge.retired { background: #fef3c7; color: #b45309; }
.badge.src { background: var(--brand-soft); color: var(--brand); }
.row-actions { display: flex; gap: 6px; }

/* 接入 */
.callout { border-radius: 13px; padding: 15px 18px; font-size: 13px; line-height: 1.7; margin-bottom: 20px; }
.callout.info { background: var(--brand-soft); color: #3730a3; border: 1px solid #dfe3ff; }
.callout b { font-weight: 750; }
.connect-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(240px,.7fr); gap: 20px; padding: 20px 22px; }
.field { display: block; margin-bottom: 6px; }
.field > span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: #334155; }
.field > span em { color: var(--danger); font-style: normal; }
.field > span i { color: var(--faint); font-style: normal; font-weight: 400; font-size: 12px; }
.editor-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.upload-btn { cursor: pointer; }
.code-area { width: 100%; height: 320px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.6; resize: vertical; color: #1e293b; background: #fbfcfe; tab-size: 2; }
.code-area:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.form-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 9px; padding: 10px 13px; font-size: 12.5px; margin-top: 10px; }
.sync-preview { border: 1px solid var(--border); border-radius: 11px; padding: 14px; min-height: 150px; background: #fbfcfe; }
.sp-empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 28px 8px; }
.sp-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12.5px; }
.sp-sum { display: flex; gap: 8px; margin-bottom: 10px; }
.sp-pill { flex: 1; text-align: center; border-radius: 8px; padding: 8px 4px; font-size: 12px; font-weight: 700; }
.sp-pill.add { background: var(--ok-soft); color: var(--ok); }
.sp-pill.upd { background: #eff6ff; color: #2563eb; }
.sp-pill.ret { background: var(--amber-soft); color: var(--amber); }
.sp-list { max-height: 180px; overflow-y: auto; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.d-add { background: var(--ok); } .d-upd { background: #2563eb; } .d-ret { background: var(--amber); }
.sp-hint { margin-top: 12px; font-size: 11.5px; color: var(--soft); display: grid; gap: 6px; }
.sp-hint > div { display: flex; align-items: center; gap: 8px; }
.connect-aside h3 { margin: 0 0 12px; font-size: 14px; }

/* 测试 */
.tester-bar { display: flex; gap: 10px; padding: 18px 22px; flex-wrap: wrap; }
.test-result { padding: 0 22px 22px; }
.result-app { font-size: 12px; color: var(--soft); margin-bottom: 10px; }
.result-block { border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; margin-top: 10px; }
.result-block h4 { margin: 0 0 10px; font-size: 13px; }
.result-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.result-chip { font-size: 12px; padding: 4px 10px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); }
.result-chip.deny { background: #fef2f2; color: var(--danger); }
.allowed-banner { padding: 12px 16px; border-radius: 10px; font-weight: 700; font-size: 13.5px; }
.allowed-banner.yes { background: var(--ok-soft); color: var(--ok); }
.allowed-banner.no { background: #fef2f2; color: var(--danger); }

/* 指南 */
.guide-hero { background: linear-gradient(125deg, #3730a3, #4f46e5 45%, #0e7490); color: #fff; border-radius: 18px; padding: 34px 36px; margin-bottom: 20px; }
.guide-hero h2 { margin: 0 0 8px; font-size: 25px; }
.guide-hero p { margin: 0; opacity: .92; font-size: 14.5px; }
.way-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 20px 22px; }
.way { border: 1px solid var(--border); border-radius: 13px; padding: 18px; }
.way-n { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 800; display: grid; place-items: center; margin-bottom: 10px; }
.way h3 { margin: 0 0 6px; font-size: 14.5px; }
.way p { margin: 0; color: var(--soft); font-size: 12.5px; line-height: 1.65; }
.steps { padding: 20px 22px; }
.step { display: flex; gap: 14px; padding: 0 0 20px; }
.step:last-child { padding-bottom: 0; }
.step-n { width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.step h4 { margin: 3px 0 5px; font-size: 14px; }
.step p { margin: 0; color: var(--soft); font-size: 12.8px; line-height: 1.7; }
.code-block { margin: 0; padding: 20px 22px; background: #0f172a; color: #e2e8f0; border-radius: 0 0 15px 15px; overflow-x: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.65; white-space: pre; }

/* 抽屉 */
.mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; justify-content: flex-end; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.drawer { width: min(620px, 100%); height: 100%; background: #fff; display: flex; flex-direction: column; box-shadow: -14px 0 40px -18px rgba(15,23,42,.4); animation: slidein .25s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-head p { margin: 4px 0 0; color: var(--soft); font-size: 12.5px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 26px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drawer-body .field input[type="text"], .drawer-body .select-input { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; font-family: inherit; }
.drawer-body .field input:focus, .drawer-body .select-input:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.drawer-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 10px; }
.perm-picker { border: 1px solid var(--border); border-radius: 11px; max-height: 260px; overflow-y: auto; padding: 6px 0; }
.perm-group { border-bottom: 1px solid #f1f5f9; }
.perm-group:last-child { border-bottom: none; }
.perm-group-title { padding: 8px 14px; font-size: 11.5px; font-weight: 700; color: var(--brand); background: #fafbff; }
.perm-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; font-size: 13px; }
.perm-item:hover { background: #fafbff; }
.perm-item input { width: 16px; height: 16px; accent-color: var(--brand); }
.perm-item .pi-name { flex: 1; }
.perm-item .pi-type { font-size: 10.5px; color: var(--faint); }
.scope-picker { border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; display: grid; gap: 12px; }
.scope-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.scope-row .sr-name { width: 130px; font-weight: 600; }
.scope-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; font-family: inherit; }
.scope-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; flex: 1; font-family: inherit; }
.grant-block { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 18px; }
.grant-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.grant-title i { color: var(--faint); font-weight: 400; font-size: 11.5px; margin-left: 6px; }
.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; cursor: pointer; background: #fff; color: var(--soft); user-select: none; }
.chip-opt:hover { border-color: #c7d2fe; }
.chip-opt.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.grant-preview { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 12px; color: var(--soft); line-height: 1.7; }

/* 确认框 / toast */
.confirm-card { background: #fff; border-radius: 15px; padding: 26px; width: min(400px, 92vw); box-shadow: var(--shadow); align-self: center; margin: auto; }
.confirm-card h3 { margin: 0 0 8px; font-size: 17px; }
.confirm-card p { margin: 0 0 20px; color: var(--soft); font-size: 13.5px; line-height: 1.6; }
.confirm-foot { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 12px 22px; border-radius: 10px; font-size: 13.5px; font-weight: 600; z-index: 100; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }
.toast.error { background: var(--danger); }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sb-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sb-group, .sb-foot { display: none; }
  .stat-grid, .level-grid, .way-grid { grid-template-columns: 1fr 1fr; }
  .connect-grid { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 50px; }
  .topbar { padding: 16px; }
}
@media (max-width: 640px) {
  .stat-grid, .level-grid, .way-grid, .form-row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   统一后台追加：门户链接配置 / 图库 / 组织架构
   ========================================================================== */

/* 链接配置页头 */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 6px 0 0; font-size: 13px; color: var(--soft); }
.head-actions { display: flex; gap: 10px; }
.list-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 13px; color: var(--soft); }
.list-meta b { color: var(--brand); }
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.link-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.link-table th { text-align: left; padding: 13px 16px; background: #f8fafc; color: var(--soft); font-weight: 700; font-size: 11.5px; letter-spacing: .3px; white-space: nowrap; }
.link-table td { padding: 13px 16px; border-bottom: 1px solid #f1f4f9; vertical-align: middle; }
.link-table tbody tr:last-child td { border-bottom: none; }
.link-table tbody tr:hover { background: #fafbff; }
.link-table .empty-row, .link-table .loading-cell { text-align: center; color: var(--faint); padding: 36px; }
/* 拖拽排序 */
.sortable-row { cursor: default; }
.sortable-row.dragging { opacity: .4; }
.sortable-row.drag-over-before td { border-top: 2px solid var(--brand) !important; }
.sortable-row.drag-over-after td { border-bottom: 2px solid var(--brand) !important; }
.thumb-cell { display: flex; align-items: center; gap: 8px; }
.drag-handle { flex: none; width: 16px; color: #b6bcc9; font-size: 15px; font-weight: 700; letter-spacing: -3px; line-height: 1; cursor: grab; user-select: none; padding: 4px 0; white-space: nowrap; }
.drag-handle:active { cursor: grabbing; color: var(--brand); }
.order-cell { text-align: center; }
.order-num { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 7px; background: #eef2ff; color: #4338ca; font-weight: 700; font-size: 12px; }
.cell-name { font-weight: 600; }
.cell-desc { margin-top: 3px; font-size: 12px; color: var(--faint); }
.cell-url { color: var(--soft); font-size: 13px; word-break: break-all; max-width: 280px; }
.cell-url a { color: var(--brand); text-decoration: none; }
.cell-url a:hover { text-decoration: underline; }
.thumb { width: 76px; height: 26px; object-fit: contain; border-radius: 5px; background: #f1f5f9; display: block; }
.thumb-fallback { width: 76px; height: 26px; border-radius: 5px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: linear-gradient(135deg, #6366f1, #0ea5e9); }
.group-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.group-badge.business { background: #eef2ff; color: #4338ca; }
.group-badge.custom { background: #ecfdf5; color: #047857; }

/* 编辑抽屉（复用 .mask/.drawer 基础，补充链接表单） */
.drawer-body .field input[type="text"], .drawer-body .field input[type="number"], .drawer-body .select-input { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; font-family: inherit; }
.image-editor { display: flex; gap: 14px; align-items: flex-start; }
.image-preview { width: 160px; height: 90px; border: 1px dashed var(--border); border-radius: 10px; background: #f8fafc; display: grid; place-items: center; color: var(--faint); font-size: 12px; flex: none; overflow: hidden; }
.image-preview img { width: 100%; height: 100%; object-fit: contain; }
.image-controls { flex: 1; min-width: 0; }
.image-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upload-btn, .gallery-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px dashed var(--border); border-radius: 9px; background: #fff; color: var(--soft); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.upload-btn:hover, .gallery-btn:hover { border-color: #c7d2fe; color: var(--brand); background: #f8faff; }
.gallery-btn { border-style: solid; background: var(--brand-soft); color: var(--brand); border-color: #dfe3ff; }
.upload-btn svg, .gallery-btn svg { width: 15px; height: 15px; }
.image-url { width: 100%; margin-top: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; font-family: inherit; }
.image-url:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.image-controls small { display: block; margin-top: 8px; font-size: 11px; color: var(--faint); line-height: 1.5; }
.size-hint { background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px !important; }
.size-hint b { color: var(--soft); }
.field-narrow { max-width: 240px; }

/* 图库大图弹窗 */
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 18px; }
.gallery-mask { z-index: 60; align-items: center; justify-content: center; }
.gallery-panel { width: 100%; max-width: 1000px; max-height: calc(100vh - 60px); display: flex; flex-direction: column; background: #fff; border-radius: 18px; box-shadow: 0 30px 70px -20px rgba(15,23,42,.4); overflow: hidden; animation: gallery-in .2s ease; }
@keyframes gallery-in { from { transform: scale(.97) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.gallery-sub { margin: 4px 0 0; font-size: 12px; color: var(--faint); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 16px; padding: 20px 24px 26px; overflow-y: auto; }
.gallery-item { position: relative; display: flex; flex-direction: column; height: 250px; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #eef2f7; cursor: pointer; padding: 0; transition: border-color .15s, transform .15s, box-shadow .15s; }
.gallery-item img { flex: 1; min-height: 0; width: 100%; object-fit: contain; display: block; background: #f1f5f9; }
.gallery-item:hover { transform: translateY(-3px); box-shadow: 0 10px 20px -8px rgba(15,23,42,.35); }
.gallery-item.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.3); }
.gallery-item.selected::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; }
.gallery-name { display: block; padding: 7px 10px; font-size: 13px; font-weight: 600; color: var(--text); text-align: left; background: #fff; }
.icon-loading { grid-column: 1 / -1; text-align: center; padding: 40px 24px; color: var(--faint); font-size: 13px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }

/* 组织架构视图 */
.org-config-grid { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(240px,.8fr); gap: 20px; padding: 20px 22px; }
.org-field { display: block; margin-bottom: 14px; }
.org-field > span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; color: #334155; }
.org-field input, .org-field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; font-family: inherit; background: #fff; }
.org-field input:focus, .org-field select:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.org-toggle { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; margin-bottom: 12px; cursor: pointer; }
.org-toggle input { width: 17px; height: 17px; accent-color: var(--brand); }
.org-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.org-stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.org-mini-stat { border: 1px solid var(--border); border-radius: 11px; padding: 14px; background: #fbfcfe; }
.org-mini-stat .n { font-size: 24px; font-weight: 800; line-height: 1; }
.org-mini-stat .l { font-size: 11.5px; color: var(--soft); margin-top: 6px; }
.org-mode-pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); }
.org-mode-pill.api { background: var(--ok-soft); color: var(--ok); }
.org-mode-pill.manual { background: #f1f5f9; color: var(--soft); }
.dept-tree { padding: 8px 0; }
.dept-node { padding: 9px 12px; border-radius: 9px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dept-node:hover { background: #f8faff; }
.dept-node .dn-name { font-weight: 600; flex: 1; }
.dept-node .dn-id { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--faint); }
.dept-node .dn-count { font-size: 11px; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; }
.dept-children { margin-left: 22px; border-left: 1px dashed var(--border); padding-left: 8px; }
.org-tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.org-tab { padding: 12px 16px; font-size: 13px; font-weight: 600; color: var(--soft); cursor: pointer; border-bottom: 2px solid transparent; }
.org-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.sync-result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.sync-result-grid .sr-cell { text-align: center; border-radius: 9px; padding: 10px 4px; font-size: 12px; font-weight: 700; }
.sr-cell.a { background: var(--ok-soft); color: var(--ok); }
.sr-cell.u { background: #eff6ff; color: #2563eb; }
.sr-cell.d { background: var(--amber-soft); color: var(--amber); }
.sr-cell.x { background: #f1f5f9; color: var(--soft); }
.badge.wecom { background: #ecfdf5; color: #047857; }
.badge.seed { background: var(--brand-soft); color: var(--brand); }
.badge.manual { background: #f1f5f9; color: var(--soft); }
.badge.lost { background: #fef3c7; color: #b45309; }
@media (max-width: 1000px) {
  .org-config-grid, .connect-grid { grid-template-columns: 1fr; }
  .sync-result-grid { grid-template-columns: repeat(2, 1fr); }
}
