/* ==========================================================================
   Settings: roles and permission matrices
   ========================================================================== */

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.role-card { display: grid; gap: 14px; align-content: start; padding: 20px; transition: box-shadow .2s, transform .2s, border-color .2s; }
.role-card:hover { box-shadow: var(--shadow-2); border-color: var(--line-strong); transform: translateY(-1px); }
.role-card__head { display: flex; align-items: center; gap: 14px; }
.role-card__head h2 { font-size: 1.1rem; margin-bottom: 4px; }
.role-card__head h2 a { color: var(--text); }
.role-card__head h2 a:hover { color: var(--text); text-decoration: underline; }
.role-card__icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.role-card__icon .icon { width: 22px; height: 22px; }
.role-card__icon--admin { background: var(--brand-badge); color: var(--brand-hover); }
.role-card__icon--manager { background: var(--info-soft); color: var(--info-ink); }
.role-card__icon--member { background: var(--success-soft); color: var(--success-ink); }
.role-card__icon--custom { background: var(--surface-3); color: var(--text-2); }
.role-card__text { color: var(--text-2); font-size: 14px; min-height: 2.9em; }
.role-card__stats { display: flex; flex-wrap: wrap; gap: 8px 26px; padding: 12px 0; border-block: 1px dashed var(--line); }
.role-card__stats dt { font-size: 12px; color: var(--text-3); font-weight: 550; }
.role-card__stats dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.role-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------- matrix ---------------------------------- */
.permission-matrix__toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--surface-2); }

.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.matrix th, .matrix td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.matrix__object { text-align: left; min-width: 230px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
thead .matrix__object { z-index: 3; background: var(--surface-2); }
.matrix__object strong { display: block; font-weight: 550; color: var(--text); }
.matrix__object small { display: block; color: var(--text-3); font-size: 12.5px; font-weight: 500; line-height: 1.35; }
.matrix__action { width: 96px; text-align: center; }
.matrix__all { width: 74px; text-align: center; }
.matrix__cell { text-align: center; }
.matrix__group th { position: static; padding: 9px 14px; text-align: left; font-size: 12px; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.matrix tbody tr:not(.matrix__group):hover th, .matrix tbody tr:not(.matrix__group):hover td { background: var(--surface-2); }
.matrix tbody:last-child tr:last-child th, .matrix tbody:last-child tr:last-child td { border-bottom: 0; }

.matrix__toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.matrix__toggle input { width: 16px; height: 16px; cursor: pointer; }
.matrix__toggle input:disabled { cursor: not-allowed; opacity: .4; }

.matrix__check { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; cursor: pointer; border-radius: 10px; }
.matrix__check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.matrix__box { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; border: 1.5px solid var(--line-strong); background: var(--surface); color: transparent; transition: all .15s var(--ease); pointer-events: none; }
.matrix__box .icon { width: 14px; height: 14px; stroke-width: 3; }
.matrix__check:hover .matrix__box { border-color: var(--brand); }
.matrix__check input:checked + .matrix__box { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); transform: scale(1.04); }
.matrix__check input:focus-visible + .matrix__box { box-shadow: var(--focus); }
.matrix__check.is-locked { cursor: not-allowed; }
.matrix__check.is-locked .matrix__box { background: var(--surface-3); border-style: dashed; opacity: .7; }
.matrix__check.is-locked input:checked + .matrix__box { background: color-mix(in srgb, var(--brand-strong) 45%, white); border-color: transparent; }
.matrix__check input:disabled { cursor: not-allowed; }

.matrix__mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.matrix__mark.is-yes { background: var(--success-soft); color: var(--success-ink); }
.matrix__mark.is-yes .icon { width: 14px; height: 14px; stroke-width: 3; }
.matrix__dash { display: inline-block; width: 10px; height: 2px; border-radius: 2px; background: var(--line-strong); }

/* transitions matrix (statuses) */
.matrix--transitions .matrix__action { width: auto; min-width: 118px; }
.matrix--transitions .matrix__object { min-width: 150px; }
.matrix--transitions thead th { text-transform: none; letter-spacing: 0; }
.matrix__corner { display: flex; justify-content: space-between; gap: 18px; font-size: 12px; }
