.role-perm {
    display: grid;
    gap: 1rem;
}

.role-perm[x-cloak],
.role-perm [x-cloak] {
    display: none !important;
}

.role-perm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    border-bottom: 1px solid var(--awdaco-border, #e5e7eb);
}

.role-perm-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 0.15rem 0.8rem;
    border: 0;
    background: transparent;
    color: var(--awdaco-muted, #6b7280);
    font-size: 0.92rem;
    font-weight: 650;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.role-perm-tab.is-active {
    color: var(--awdaco-primary, #2B337E);
    border-bottom-color: var(--awdaco-primary, #2B337E);
}

.role-perm-badge {
    min-width: 1.4rem;
    padding: 0.08rem 0.38rem;
    border-radius: 999px;
    background: rgba(43, 51, 126, 0.1);
    color: var(--awdaco-primary, #2B337E);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

.role-perm-tab.is-active .role-perm-badge {
    background: rgba(43, 51, 126, 0.16);
    color: var(--awdaco-primary-dark, #20275F);
}

.role-perm-panel {
    display: grid;
    gap: 0.85rem;
}

.role-perm-empty {
    margin: 0;
    padding: 1.25rem;
    border: 1px dashed var(--awdaco-border, #e5e7eb);
    border-radius: 12px;
    color: var(--awdaco-muted, #6b7280);
    background: #fff;
}

.role-perm-card {
    background: #fff;
    border: 1px solid var(--awdaco-border, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
}

.role-perm-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1.1rem;
    cursor: pointer;
    list-style: none;
}

.role-perm-card-head::-webkit-details-marker,
.role-perm-card-head::marker {
    display: none;
}

.role-perm-card-head span {
    display: grid;
    gap: 0.15rem;
}

.role-perm-card-head strong {
    font-size: 0.98rem;
    font-weight: 750;
    color: var(--awdaco-text, #1f2937);
}

.role-perm-card-head small {
    color: #9ca3af;
    font-size: 0.78rem;
}

.role-perm-chevron {
    width: 1.1rem;
    height: 1.1rem;
    color: #9ca3af;
    transition: transform 0.16s ease;
}

.role-perm-card:not([open]) .role-perm-chevron {
    transform: rotate(180deg);
}

.role-perm-card-body {
    padding: 0 1.1rem 1.1rem;
}

.role-perm-select-all {
    display: inline-block;
    margin-bottom: 0.75rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--awdaco-primary, #2B337E);
    font-size: 0.86rem;
    font-weight: 650;
    cursor: pointer;
}

.role-perm-select-all:hover {
    text-decoration: underline;
}

.role-perm-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem 1rem;
}

.role-perm-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 1.6rem;
    font-size: 0.9rem;
    color: var(--awdaco-text, #1f2937);
    cursor: pointer;
}

.role-perm-option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    flex-shrink: 0;
    border: 1.5px solid #d1d5db;
    border-radius: 0.3rem;
    background: #fff;
    display: grid;
    place-content: center;
    cursor: pointer;
}

.role-perm-option input[type="checkbox"]:checked {
    background: var(--awdaco-primary, #2B337E);
    border-color: var(--awdaco-primary, #2B337E);
}

.role-perm-option input[type="checkbox"]:checked::after {
    content: "";
    width: 0.28rem;
    height: 0.5rem;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.role-perm-option input[type="checkbox"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.role-perm-basics {
    border: 1px solid var(--awdaco-border, #e5e7eb) !important;
    border-radius: 12px !important;
}

.dark .role-perm-option input[type="checkbox"] {
    background: transparent;
    border-color: #4b5563;
}

.dark .role-perm-card,
.dark .role-perm-empty {
    background: var(--awdaco-surface, #1c224d);
    border-color: var(--awdaco-border, #30365e);
}

.dark .role-perm-card-head strong,
.dark .role-perm-option {
    color: var(--awdaco-text, #f8fafc);
}

.dark .role-perm-badge,
.dark .role-perm-tab.is-active .role-perm-badge {
    background: rgba(104, 111, 174, 0.22);
    color: var(--awdaco-primary, #686FAE);
}

@media (max-width: 900px) {
    .role-perm-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .role-perm-grid {
        grid-template-columns: 1fr;
    }
}

/* Permission matrix controls */
.role-perm-toolbar { display:flex; align-items:center; justify-content:space-between; gap:.75rem; flex-wrap:wrap; }
.role-perm-search { display:flex; align-items:center; gap:.55rem; width:min(100%,32rem); min-height:2.65rem; padding:0 .85rem; border:1px solid var(--awdaco-border,#dbe0e8); border-radius:10px; background:#fff; }
.role-perm-search svg { width:1rem; height:1rem; color:#9ca3af; }
.role-perm-search input { width:100%; border:0; outline:0; background:transparent; font-size:.9rem; }
.role-perm-toolbar-actions,.role-perm-presets { display:flex; align-items:center; gap:.45rem; flex-wrap:wrap; }
.role-perm-toolbar-actions button,.role-perm-presets button { min-height:2.15rem; padding:.35rem .7rem; border:1px solid var(--awdaco-border,#dbe0e8); border-radius:8px; background:#fff; color:var(--awdaco-text,#374151); font-size:.8rem; font-weight:650; cursor:pointer; }
.role-perm-toolbar-actions button:hover,.role-perm-presets button:hover { border-color:var(--awdaco-primary,#2B337E); color:var(--awdaco-primary,#2B337E); background:rgba(43,51,126,.05); }
.role-perm-presets>span { color:var(--awdaco-muted,#6b7280); font-size:.82rem; font-weight:650; }
.role-perm-option.is-sensitive { color:#b45309; }
.role-perm-option.is-sensitive input[type="checkbox"] { border-color:#f59e0b; }
.role-perm-option.is-sensitive input[type="checkbox"]:checked { background:#d97706; border-color:#d97706; }
.fi-resource-role-resource .fi-form-actions,.fi-resource-role .fi-form-actions { position:sticky; bottom:0; z-index:20; padding:.85rem 1rem!important; border:1px solid var(--awdaco-border,#e5e7eb); border-radius:12px; background:rgba(255,255,255,.96); box-shadow:0 -8px 24px rgba(15,23,42,.08); backdrop-filter:blur(10px); }
.dark .role-perm-search,.dark .role-perm-toolbar-actions button,.dark .role-perm-presets button { background:var(--awdaco-surface,#1c224d); border-color:var(--awdaco-border,#30365e); color:var(--awdaco-text,#f8fafc); }
@media(max-width:640px){.role-perm-toolbar{align-items:stretch}.role-perm-search{width:100%}.role-perm-toolbar-actions{width:100%}.role-perm-toolbar-actions button{flex:1}}/* Role permissions reference redesign */
.role-perm-basics {
    padding: 1.75rem 1.5rem !important;
    border-color: #dde3ed !important;
    border-radius: 14px !important;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .02);
}
.role-perm-basics .fi-section-header {
    align-self: stretch;
    padding-right: 1.75rem;
    border-right: 1px solid #e2e7ef;
}
.role-perm-basics .fi-section-header-icon {
    width: 3.5rem;
    height: 3.5rem;
    padding: .85rem;
    border-radius: 12px;
    color: #6557e8;
    background: #f1efff;
}
.role-perm-basics .fi-section-header-heading { font-size: 1rem; font-weight: 750; }
.role-perm-basics .fi-section-header-description { color: #64748b; line-height: 1.5; }
.role-perm-basics .fi-input-wrp { min-height: 3.1rem; border-radius: 10px; box-shadow: 0 0 0 1px #dce2eb; }
.role-perm-basics .fi-fo-field-wrp-label { font-weight: 700; }
.role-perm {
    gap: 1.4rem;
    padding: 1.5rem;
    border: 1px solid #dde3ed;
    border-radius: 14px;
    background: #fff;
}
.role-perm-toolbar { gap: 1rem; }
.role-perm-search { width: min(100%, 25rem); min-height: 3rem; border-color: #dce2eb; border-radius: 10px; }
.role-perm-search:focus-within { border-color: #7668ee; box-shadow: 0 0 0 3px rgba(118,104,238,.1); }
.role-perm-search svg { width: 1.15rem; height: 1.15rem; color: #64748b; }
.role-perm-toolbar-actions { gap: .75rem; margin-left: auto; }
.role-perm-toolbar-actions button { display: inline-flex; align-items: center; gap: .5rem; min-height: 3rem; padding: .55rem 1rem; border-color: #dce2eb; border-radius: 10px; font-size: .875rem; }
.role-perm-toolbar-actions button svg { width: 1rem; height: 1rem; }
.role-perm-presets { gap: .65rem; }
.role-perm-presets > span { margin-right: .25rem; color: #475569; font-weight: 750; }
.role-perm-presets button { min-height: 2.5rem; padding: .45rem .9rem; border-radius: 10px; }
.role-perm-presets button:last-child { border-color: transparent; color: #5545df; background: #f2efff; }
.role-perm-tabs { gap: 2.25rem; margin-top: .1rem; }
.role-perm-tab { gap: .65rem; padding: .75rem 0 1rem; font-size: .95rem; }
.role-perm-tab.is-active { color: #5b4ce3; border-bottom-color: #6557e8; }
.role-perm-badge { padding: .18rem .55rem; background: #eef1f5; color: #566176; font-size: .74rem; }
.role-perm-tab.is-active .role-perm-badge { color: #5545df; background: #f0edff; }
.role-perm-panel { gap: 1rem; }
.role-perm-card { border-color: #e0e5ed; border-radius: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.015); }
.role-perm-card-head { min-height: 5.5rem; padding: 1rem 1.25rem; }
.role-perm-card-identity { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 1rem !important; }
.role-perm-card-icon { display: grid !important; place-items: center; flex: 0 0 3.5rem; width: 3.5rem; height: 3.5rem; border-radius: 11px; color: #6657eb; background: #f2efff; }
.role-perm-card-icon svg { width: 1.6rem; height: 1.6rem; }
.role-perm-card-copy { display: grid !important; gap: .2rem !important; }
.role-perm-card-head strong { font-size: 1rem; color: #111827; }
.role-perm-card-head small { color: #64748b; font-size: .85rem; }
.role-perm-card-meta { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 1.25rem !important; }
.role-perm-selected-pill { display: inline-flex; padding: .35rem .65rem; border: 1px solid #e1e6ed; border-radius: 999px; color: #64748b; background: #f8fafc; font-size: .78rem; line-height: 1; white-space: nowrap; }
.role-perm-chevron { width: 1rem; height: 1rem; color: #475569; }
.role-perm-card-body { padding: .25rem 1.25rem 1.25rem 5.75rem; border-top: 1px solid #eef1f5; }
.dark .role-perm, .dark .role-perm-basics { background: var(--awdaco-surface,#1c224d); border-color: var(--awdaco-border,#30365e) !important; }
.dark .role-perm-basics .fi-section-header { border-color: var(--awdaco-border,#30365e); }
.dark .role-perm-card-icon { background: rgba(104,111,174,.2); color: #a9a3ff; }
.dark .role-perm-selected-pill { background: rgba(255,255,255,.04); border-color: #3b426b; color: #cbd5e1; }
@media (max-width: 900px) {
    .role-perm-basics .fi-section-header { padding-right: 0; padding-bottom: 1rem; border-right: 0; border-bottom: 1px solid #e2e7ef; }
    .role-perm { padding: 1rem; }
}
@media (max-width: 640px) {
    .role-perm-card-head { min-height: 4.75rem; padding: .85rem; }
    .role-perm-card-icon { flex-basis: 2.75rem; width: 2.75rem; height: 2.75rem; }
    .role-perm-selected-pill { display: none; }
    .role-perm-card-body { padding: 1rem; }
}