.lookupRow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--space-3);
}

.lookupButton {
    min-width: 92px;
}

.targetPanel {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--bg-card-strong);
}

.existingWarning {
    padding: var(--space-3);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-control);
    background: var(--danger-surface);
    color: var(--danger);
    font-size: 13px;
    line-height: 20px;
}

.accountCell {
    display: grid;
    min-width: 0;
    gap: var(--space-1);
}

.accountName {
    overflow: hidden;
    color: var(--text-primary);
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.accountMeta {
    overflow: hidden;
    color: var(--text-tertiary);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.permissionSelector {
    display: grid;
    min-width: 0;
    gap: var(--space-3);
}

.permissionToolbar {
    display: flex;
    min-height: var(--control-height);
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.permissionToolbar > strong {
    color: var(--text-primary);
    font-size: var(--control-font-size);
}

.permissionToolbarActions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.permissionToolbarActions :global(.MuiButton-root) {
    min-width: 64px;
}

.permissionGroups {
    display: grid;
    gap: var(--space-3);
}

.permissionGroup {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--bg-card);
}

.permissionGroupHeader {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-card-strong);
}

.permissionGroupHeader > strong {
    color: var(--text-primary);
    font-size: var(--control-font-size);
}

.permissionGroupHeader label {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--text-tertiary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.permissionOptions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    padding: var(--space-3);
}

.permissionOption {
    display: flex;
    min-width: 0;
    min-height: 48px;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--bg-card-strong);
    cursor: pointer;
    transition:
        border-color var(--motion-fast) var(--ease-standard),
        background var(--motion-fast) var(--ease-standard),
        transform var(--motion-base) var(--ease-emphasized);
}

.permissionOption:hover {
    border-color: var(--primary-border-strong);
    background: var(--primary-hover);
}

.permissionOption:active {
    transform: scale(0.99);
}

.permissionOption > span {
    min-width: 0;
}

.permissionOption strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.permissionOption strong {
    color: var(--text-primary);
    font-size: var(--control-font-size);
}

.permissionState {
    display: grid;
    min-height: 150px;
    place-items: center;
    align-content: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    color: var(--text-tertiary);
    text-align: center;
}

.permissionDrawerBody {
    align-content: start;
}

@media (max-width: 760px) {
    .lookupRow {
        grid-template-columns: 1fr;
    }

    .lookupButton {
        width: 100%;
    }

    .permissionToolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .permissionToolbarActions,
    .permissionToolbarActions :global(.MuiButton-root) {
        width: 100%;
    }

    .permissionOptions {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .permissionOption {
        transition: none;
    }
}
