/* ============================================================
   通用弹窗 Modal
   ============================================================ */
body.modal-lock { overflow: hidden; }
.modal {
    position: fixed; inset: 0; z-index: 1000;
    display: none;
}
.modal.is-open { display: block; }
.modal-overlay {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, .45);
    animation: modalFade .15s ease;
}
.modal-box {
    position: relative;
    width: calc(100% - 32px); max-width: 720px;
    max-height: 88vh; margin: 5.5vh auto 0;
    background: var(--card, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius-card, 10px);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
    display: flex; flex-direction: column;
    animation: modalPop .18s ease;
}
.modal-head {
    display: flex; align-items: center; gap: 10px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.modal-title { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close {
    margin-left: auto;
    width: 30px; height: 30px; border: 0; padding: 0;
    background: transparent; border-radius: 8px;
    font-size: 18px; color: var(--muted, #6b7280);
    cursor: pointer;
}
.modal-close:hover { background: var(--surface-2, #f3f4f6); color: var(--text, #111827); }
/* 弹窗内嵌 form 时（如用户组编辑），form 作为 flex 子项必须可收缩，
   否则内容会把弹窗撑出视口、底部按钮被裁掉且 body 滚动失效；
   不设置拉伸（grow=0），多表单弹窗内容不足时不会出现空白缝隙 */
.modal-box > form {
    display: flex; flex-direction: column;
    flex: 0 1 auto; min-height: 0;
}
.modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1 1 auto; min-height: 0;
}
.modal-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex; align-items: center; gap: 10px; justify-content: flex-end;
}
.modal-foot .modal-hint { margin-right: auto; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* 弹窗内分区：基础信息 / 谁能看到 / 谁能管理 */
.modal-section { margin-bottom: 16px; }
.modal-section:last-child { margin-bottom: 4px; }
.modal-section-head {
    display: flex; align-items: baseline; gap: 8px;
    margin: 0 0 8px;
    font-size: 14px; font-weight: 700;
}
.modal-section-head .ms-hint { font-weight: 400; font-size: 12px; color: var(--muted, #6b7280); }
.modal-section + .modal-section {
    border-top: 1px dashed var(--border, #e5e7eb);
    padding-top: 14px;
}

/* ============================================================
   紧凑选择面板 picker：固定高滚动 + 搜索 + 多列网格
   ============================================================ */
.picker-filter {
    width: 100%; margin-bottom: 8px;
    padding: 7px 10px;
}
/* 名称搜索 + 按组筛选 同一行 */
.picker-toolbar {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-bottom: 8px;
}
.picker-toolbar .picker-filter { flex: 1; min-width: 150px; margin-bottom: 0; }
.picker-group {
    padding: 7px 10px;
    max-width: 200px;
}
.picker-box {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: var(--surface-1, #f8fafc);
    max-height: 132px; overflow-y: auto;
    padding: 8px 10px;
}
.picker-box label.chk {
    display: inline-flex; align-items: center; gap: 5px;
    width: auto; min-width: 130px;
    margin: 2px 14px 4px 0;
    font-size: 13px;
}
.picker-box label.chk input[type="checkbox"]:disabled + * ,
.picker-box label.chk input[type="checkbox"]:disabled ~ span { color: var(--muted, #6b7280); }
.picker-empty { color: var(--muted, #6b7280); font-size: 13px; padding: 6px 2px; }
.picker-box label.chk { padding: 2px 6px; border-radius: 6px; transition: background .12s ease; }
.picker-box label.chk:hover { background: var(--primary-soft, #eef2ff); }

/* 列表行中的摘要 pill（可见范围 / 管理授权） */
.scope-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--surface-2, #f3f4f6);
    font-size: 12px; color: var(--muted, #6b7280);
    white-space: nowrap;
}
.scope-pill.is-public { background: var(--primary-soft, #eef2ff); color: var(--primary, #2563eb); }
.scope-pill.is-manage { background: #fff7e0; color: #b45309; }
.page-head-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.page-head-bar .ph-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 768px) {
  .modal-box { margin: 3vh auto 0; max-height: 94vh; }
  .picker-box label.chk { min-width: 0; margin-right: 8px; }
  .page-head-bar .ph-actions { margin-left: 0; }
}

/* picker 内来源小标签（二级授权：组权限/用户授权） */
.mini-tag {
    display: inline-block;
    font-size: 10px; line-height: 16px;
    padding: 0 5px; margin-left: 2px;
    border-radius: 4px; font-weight: 600;
    vertical-align: middle;
}
.mini-tag.tag-group { background: #dbeafe; color: #1d4ed8; }
.mini-tag.tag-user  { background: #fef3c7; color: #92400e; }
.delegate-cat .picker-box { max-height: 150px; }

