.permissions-page {
  --perm-accent: #71509a;
  --perm-accent-strong: #5f3e86;
  --perm-accent-soft: #f2edf8;
  --perm-ink: #262238;
  --perm-muted: #77748a;
}
.permissions-page .page-heading { margin-bottom: 22px; }
.permissions-page .page-heading h1 { color: var(--perm-ink); }
.perm-heading-note { margin-top: 6px; color: var(--perm-muted); font-size: 14px; }
.perm-total { padding: 5px 10px; border: 1px solid #e5deee; border-radius: 20px; color: var(--perm-accent-strong); background: #faf8fc; font-size: 12px; font-weight: 650; white-space: nowrap; }
.perm-layout { display: grid; grid-template-columns: minmax(255px, 310px) minmax(0, 1fr); align-items: start; gap: 18px; }
.perm-member-panel { display: flex; min-width: 0; max-height: calc(100dvh - 190px); flex-direction: column; }
.perm-panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 12px 17px; border-bottom: 1px solid #ece9f0; }
.perm-panel-head h2 { margin: 0; color: var(--perm-ink); font-size: 15px; font-weight: 700; }
.perm-panel-head small { color: var(--perm-muted); font-size: 12px; }
.perm-panel-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; color: var(--perm-accent); background: var(--perm-accent-soft); }
.perm-search { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 13px 13px 9px; padding: 0 10px; border: 1px solid #e4e0e9; border-radius: 8px; color: #8d8998; background: #fff; }
.perm-search:focus-within { border-color: #b9a4cf; box-shadow: 0 0 0 3px #71509a14; }
.perm-search input { width: 100%; min-width: 0; height: 38px; padding: 0; border: 0; outline: 0; color: var(--perm-ink); background: transparent; font-size: 13px; }
.perm-search input::placeholder { color: #aaa6b2; }
.perm-member-list { min-height: 120px; overflow: auto; padding: 3px 8px 10px; scrollbar-width: thin; scrollbar-color: #d8d1e1 transparent; }
.perm-member-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 60px; padding: 8px 9px; border: 0; border-radius: 9px; color: var(--perm-ink); background: transparent; text-align: left; cursor: pointer; }
.perm-member-row:hover { background: #f8f6fa; }
.perm-member-row.is-selected { background: var(--perm-accent-soft); box-shadow: inset 3px 0 var(--perm-accent); }
.perm-member-row:focus-visible { outline: 2px solid #a88bc4; outline-offset: 1px; }
.perm-avatar { position: relative; display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; overflow: hidden; border: 1px solid #ece8f1; border-radius: 50%; color: #65577b; background: #f1edf5; font-size: 14px; font-weight: 700; }
.perm-avatar .avatar-content { width: 100%; height: 100%; }
.perm-member-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.perm-member-copy strong { overflow: hidden; color: #29263a; font-size: 13px; font-weight: 670; text-overflow: ellipsis; white-space: nowrap; }
.perm-member-copy small { overflow: hidden; color: #858194; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.perm-member-meta { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.perm-role-badge { padding: 3px 7px; border: 1px solid #e5e2e9; border-radius: 5px; color: #6e6a79; background: #faf9fb; font-size: 10px; font-weight: 650; line-height: 1.3; white-space: nowrap; }
.perm-role-badge.is-admin { border-color: #e0d2ef; color: var(--perm-accent-strong); background: #f4eef9; }
.perm-dirty-dot,.perm-saving-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #d59138; }
.perm-saving-dot { border: 1.5px solid #a68ab9; border-top-color: transparent; background: transparent; animation: perm-spin .8s linear infinite; }
.perm-loading,.perm-list-empty,.perm-list-error { display: grid; justify-items: center; gap: 9px; padding: 34px 15px; color: #8b8795; text-align: center; font-size: 13px; }
.perm-list-error { color: #a23d4a; }
.perm-retry { color: var(--perm-accent-strong); font-size: 12px; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.perm-editor-panel { min-width: 0; min-height: 440px; }
.perm-editor-body { min-height: 440px; padding: 23px clamp(18px, 2.4vw, 32px); }
.perm-editor-empty { display: grid; min-height: 390px; justify-items: center; align-content: center; gap: 11px; color: var(--perm-muted); font-size: 13px; text-align: center; }
.perm-editor-empty-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; color: var(--perm-accent); background: var(--perm-accent-soft); }
.perm-spinner { width: 20px; height: 20px; border: 2px solid #e8e3ed; border-top-color: var(--perm-accent); border-radius: 50%; animation: perm-spin .8s linear infinite; }
.perm-user-header { display: flex; align-items: center; gap: 13px; min-height: 59px; padding-bottom: 19px; border-bottom: 1px solid #eeeaf2; }
.perm-avatar-large { width: 48px; height: 48px; font-size: 17px; }
.perm-user-title { display: grid; min-width: 0; flex: 1; gap: 1px; }
.perm-user-title small { overflow: hidden; color: #888496; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.perm-user-title h2 { overflow: hidden; color: var(--perm-ink); font-size: 18px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.perm-role-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 12px; padding: 14px 15px; border: 1px solid #e7e0ef; border-radius: 10px; background: #fbf9fd; }
.perm-role-copy { display: grid; gap: 3px; }
.perm-role-copy strong { color: #342d42; font-size: 14px; }
.perm-role-copy span { color: #817c8e; font-size: 12px; line-height: 1.4; }
.perm-toggle { position: relative; display: inline-flex; width: 42px; height: 24px; flex: 0 0 auto; cursor: pointer; }
.perm-toggle input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.perm-switch { position: relative; display: block; width: 42px; height: 24px; border: 1px solid #d5d1dc; border-radius: 20px; background: #eceaf0; transition: background .14s, border-color .14s; }
.perm-switch::after { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #2420362b; content: ""; transition: transform .14s; }
.perm-toggle input:checked + .perm-switch { border-color: var(--perm-accent); background: var(--perm-accent); }
.perm-toggle input:checked + .perm-switch::after { transform: translateX(18px); }
.perm-toggle input:focus-visible + .perm-switch { outline: 3px solid #71509a35; outline-offset: 2px; }
.perm-toggle input:disabled + .perm-switch { opacity: .6; cursor: not-allowed; }
.perm-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.perm-section-heading h3 { color: #342e42; font-size: 14px; font-weight: 700; }
.perm-section-heading p { margin-top: 3px; color: #898594; font-size: 11px; }
.perm-settings { display: grid; border-top: 1px solid #eeeaf2; }
.perm-setting-row { display: grid; grid-template-columns: 32px minmax(0,1fr) minmax(86px,auto) 42px; align-items: center; gap: 11px; min-height: 66px; border-bottom: 1px solid #f0edf3; }
.perm-setting-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; color: #77648d; background: #f5f2f8; }
.perm-setting-copy { display: grid; min-width: 0; gap: 2px; }
.perm-setting-copy strong { color: #302b3c; font-size: 13px; font-weight: 650; }
.perm-setting-copy small { overflow: hidden; color: #898594; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.perm-effective { justify-self: end; color: #92909a; font-size: 10px; white-space: nowrap; }
.perm-effective.is-granted { color: #6c4c8b; font-weight: 650; }
.perm-form-feedback { min-height: 30px; padding-top: 8px; }
.perm-error,.perm-saved { margin: 0; font-size: 12px; line-height: 1.45; }
.perm-error { color: #a63d46; }
.perm-saved { color: #49745a; }
.perm-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding-top: 8px; }
.perm-reset { padding: 8px 10px; color: #777283; font-size: 12px; font-weight: 600; }
.perm-reset:hover:not(:disabled) { color: var(--perm-accent-strong); }
.perm-reset:disabled { opacity: .45; cursor: default; }
.permissions-page .perm-save { border-color: var(--perm-accent-strong); background: var(--perm-accent); }
.permissions-page .perm-save:hover:not(:disabled) { background: var(--perm-accent-strong); }
.permissions-page .perm-save:disabled { opacity: .48; cursor: default; }
.perm-denied { display: flex; align-items: flex-start; gap: 16px; max-width: 620px; margin: 46px auto; padding: 26px; }
.perm-denied-icon { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 13px; color: #76539b; background: #f2edf8; }
.perm-denied h1 { color: var(--perm-ink); font-size: 20px; }
.perm-denied p { margin: 8px 0 17px; color: #766f81; font-size: 13px; }
.permissions-page .btn.primary { border-color: var(--perm-accent); background: var(--perm-accent); }
.permissions-page .btn.primary:hover { background: var(--perm-accent-strong); }
@keyframes perm-spin { to { transform: rotate(360deg); } }
@media (max-width: 880px) {
  .permissions-page.page-frame { padding: 22px 18px 32px; }
  .perm-layout { grid-template-columns: minmax(220px, .78fr) minmax(0,1.4fr); gap: 12px; }
  .perm-editor-body { padding: 19px 17px; }
}
@media (max-width: 680px) {
  .permissions-page.page-frame { padding: 18px 12px 26px; }
  .permissions-page .page-heading { margin-bottom: 15px; }
  .perm-layout { grid-template-columns: minmax(0,1fr); }
  .perm-member-panel { max-height: 320px; }
  .perm-member-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(210px,1fr)); gap: 2px; }
  .perm-editor-panel,.perm-editor-body { min-height: 0; }
  .perm-setting-row { grid-template-columns: 30px minmax(0,1fr) 42px; gap: 9px; padding: 7px 0; }
  .perm-effective { grid-column: 2; grid-row: 2; justify-self: start; margin-top: -8px; }
  .perm-setting-row > .perm-toggle { grid-column: 3; grid-row: 1 / span 2; }
  .perm-role-card { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .perm-spinner,.perm-switch,.perm-switch::after { animation: none; transition: none; }
}
