.profiles-page .back-button {
    margin-bottom: 24px
}

.profiles-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 28px
}

.profiles-heading h1 {
    font: 800 29px 'Manrope', sans-serif;
    letter-spacing: -1px;
    margin: 9px 0
}

.profiles-heading h1>span {
    color: var(--orange)
}

.profiles-heading p {
    font-size: 11px;
    color: var(--text-faint);
    margin: 0
}

.admin-badge {
    display: flex;
    gap: 7px;
    align-items: center;
    font-size: 9px;
    color: var(--purple-text);
    border: 1px solid var(--purple-border);
    padding: 8px 11px;
    background: var(--purple-soft);
    border-radius: var(--radius)
}

.profiles-layout {
    display: grid;
    grid-template-columns: minmax(220px, .9fr) minmax(0, 1.7fr);
    gap: 22px;
    align-items: start
}

.profile-list-panel,
.profile-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px
}

.profile-list-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px
}

.profile-list-title h2,
.profile-form-title h2 {
    font: 700 14px 'Manrope', sans-serif;
    margin: 0
}

.profile-list-panel .module-search {
    width: 100%
}

.profile-list-panel .module-search input {
    width: 100%
}

.profile-list {
    margin-top: 15px;
    max-height: 470px;
    overflow: auto
}

.profile-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-subtle)
}

.profile-row.selected {
    background: var(--primary-faint);
    border-radius: var(--radius);
    padding: 15px 8px
}

.profile-avatar {
    height: 38px;
    width: 38px;
    border-radius: var(--radius-lg);
    background: var(--primary-faint);
    color: var(--primary-text);
    display: grid;
    place-items: center;
    flex-shrink: 0
}

.profile-avatar.is-admin {
    color: var(--purple-text);
    background: var(--purple-soft)
}

.profile-row>div {
    min-width: 0;
    flex: 1
}

.profile-row strong {
    display: block;
    font-size: 11px;
    color: var(--text-2);
    overflow-wrap: anywhere
}

.profile-row button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    height: 28px;
    width: 28px;
    border-radius: var(--radius)
}

.profile-row button:hover {
    color: var(--blue);
    border-color: var(--blue)
}

.profile-policy {
    display: flex;
    gap: 9px;
    padding: 14px 0 0;
    color: var(--text-faint);
    align-items: flex-start;
    margin-top: 12px
}

.profile-policy svg {
    flex-shrink: 0
}

.profile-policy p {
    font-size: 9px;
    line-height: 1.7;
    margin: 0
}

.profile-empty {
    font-size: 11px;
    color: var(--text-faint);
    text-align: center;
    margin: 30px 0
}

.profile-form-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 26px
}

.profile-form-icon {
    display: grid;
    place-items: center;
    width: 35px;
    height: 35px;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    color: var(--orange)
}

.new-profile {
    display: flex;
    gap: 5px;
    align-items: center;
    border: 0;
    background: none;
    color: var(--blue);
    font-size: 9px
}

.profile-form>label {
    color: var(--text-2);
    font-size: 10px;
    margin-bottom: 9px
}

.profile-name-input {
    outline-color: var(--focus-ring);
    border: 1px solid var(--border);
    width: 100%;
    color: var(--text-2);
    background: var(--field-bg)
}

.profile-name-input::placeholder {
    color: var(--text-faint)
}

.permission-heading {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin: 28px 0 16px
}

.permission-heading h3 {
    font-size: 11px;
    margin: 0;
    color: var(--text-2)
}

.permission-heading p {
    font-size: 9px;
    color: var(--text-faint);
    margin: 6px 0 0
}

.permission-heading>span {
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap
}

.permission-option {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    margin: 0;
    cursor: pointer
}

.permission-option.checked {
    border-color: var(--primary-border);
    background: var(--primary-faint)
}

.permission-option input {
    accent-color: var(--blue);
    margin: 0
}

.permission-option strong {
    display: block;
    font-weight: 500;
    color: var(--text-muted)
}

.permission-option small {
    display: block;
    font-weight: 400;
    color: var(--text-faint)
}

.permission-note {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 8px;
    color: var(--text-faint);
    margin-top: 18px;
    line-height: 1.6
}

.permission-note svg {
    flex-shrink: 0
}

.profile-form-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle)
}

.profile-save {
    display: flex;
    gap: 7px;
    align-items: center;
    border: 0;
    background: var(--button-primary);
    color: var(--on-button-primary);
    font-weight: 600
}

.profile-save:hover:not(:disabled) {
    background: var(--button-primary-hover)
}

.profile-cancel {
    background: none;
    border: 0;
    color: var(--text-faint);
    font-size: 10px;
    display: inline-flex;
    align-items: center
}

.profile-success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--success-soft);
    border: 1px solid var(--success-border);
    border-radius: var(--radius);
    font-size: 11px;
    color: var(--success-text);
    margin-top: 18px
}

@media(max-width:1000px) {
    .profiles-layout {
        grid-template-columns: 1fr
    }

    .profile-list {
        max-height: 240px
    }

    .profiles-heading h1 {
        font-size: 26px
    }

    .profile-list-panel,
    .profile-form {
        padding: 20px
    }
}

@media(max-width:450px) {
    .profiles-heading {
        align-items: flex-start
    }

    .admin-badge {
        font-size: 8px;
        padding: 7px
    }

    .permission-heading {
        flex-wrap: wrap
    }

    .profile-form-title h2 {
        font-size: 13px
    }
}

/* Permission tree (wms-profiles): menu section › screen › function over the tree of Endereçamento (addresses.css: .address-tree-panel,
   .address-tree, .tree-row, .tree-toggle, .tree-spacer, .tree-label, .tree-type). Only colors and layout here; row and checkbox sizes in forms.css. */
.permission-tree-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px
}

.permission-tree-tools .module-search {
    flex: 1 1 200px;
    width: auto;
    min-width: 0
}

.permission-tree-tools .module-search input {
    width: 100%
}

.address-tree-panel.permission-tree-panel {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 4px 6px;
    margin: 0;
    contain: inline-size
}

.permission-tree .tree-label {
    cursor: pointer
}

.permission-tree .tree-label input {
    accent-color: var(--blue);
    margin: 0
}

.permission-tree .tree-label strong {
    flex: 0 1 auto;
    min-width: 0;
    font-weight: 600
}

.permission-tree .tree-label small:not(.tree-type) {
    flex: 1 1 0;
    min-width: 0
}

.permission-tree .tree-label small.tree-type {
    margin-left: auto
}

.permission-tree .tree-row.is-section strong {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--text-muted)
}

.permission-tree .tree-row.is-function strong {
    font-weight: 500
}

.permission-tree .tree-row.is-on>.tree-label strong {
    color: var(--primary-text)
}

.permission-tree .tree-label:has(input:disabled) {
    cursor: default
}

.permission-tree .tree-row.is-function .tree-label:has(input:disabled) strong {
    color: var(--text-faint)
}

.permission-tree .tree-row.is-locked.is-on .tree-label strong {
    color: var(--primary-text)
}

.permission-count {
    flex-shrink: 0;
    font-style: normal;
    font-size: 8px;
    font-weight: 600;
    color: var(--text-faint);
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-right: 4px;
    font-variant-numeric: tabular-nums
}

.permission-count.is-mixed {
    color: var(--accent-text);
    background: var(--accent-soft)
}

.permission-count.is-on {
    color: var(--primary-text);
    background: var(--primary-faint)
}